//
//  UnitBlock.cpp
//  FingerBlock
//
//  Created by GaoFeng on 14-5-29.
//
//

#include "UnitBlock.h"

UnitBlock::UnitBlock()
{
    CCLOG("Create UnitBlock");
}

UnitBlock::~UnitBlock()
{
    CCLOG("Delete UnitBlock");
}

UnitBlock * UnitBlock::create()
{
    UnitBlock * pRet = new UnitBlock();
    if (pRet && pRet->init())
    {
        pRet->autorelease();
    }
    else
    {
        CC_SAFE_DELETE(pRet);
    }
    return pRet;
}

void UnitBlock::setData(cocos2d::CCSize size, ccColor3B color)
{
    setContentSize(size);
    setAnchorPoint(ccp(0, 0));
    setTextureRect(CCRect(0, 0, size.width, size.height));
    setColor(color);
}

bool UnitBlock::init()
{
    if (CCSprite::init())
    {        
        return true;
    }
    
    return false;
}

bool UnitBlock::PtInside(cocos2d::CCPoint pt)
{
    float posx = getPositionX();
    float posy = getPositionY();
    float sizew = getContentSize().width;
    float sizeh = getContentSize().height;
    
    return (pt.x >= posx && pt.x <= (posx+sizew)
            && pt.y >= posy && pt.y <= (posy+sizeh));
}